package org.wlw;


import com.sun.xml.internal.ws.addressing.WsaActionUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestMap {
    public static void main(String[] args) {
        //map的键是不会重复的，类似HashSet
        Map<String,Integer> map = new HashMap<>();
        map.put("张三",22);
        map.put("李四",33);
        map.put("a",22);
        map.put("b",21);
        System.out.println(map.size());
        System.out.println(map.get("b"));
        map.put("b",99);//此时不会添加，只会修改
        System.out.println("------------------------------");
        System.out.println(map.size());
        System.out.println(map.get("b"));
        System.out.println("--------------------------------");
        System.out.println(map.containsKey("a"));//判断是否有a存在
        System.out.println(map.containsValue(33));//看看有没有这个值存在
        map.remove("a");//把a这个键删除
        System.out.println(map.get("a"));
//        map.clear();//清空map
//        System.out.println(map.size());
        System.out.println("-------------------------------");
        //1、获取key
        Set<String> keys = map.keySet();
        System.out.println(keys);
        for(String key:keys) {
            System.out.println(key+":"+map.get(key));
        }
    }
}
